package gold.digger;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by fanzhenyu02 on 2020/6/27.
 * common problem solver template.
 */
public class LC841 {
    public long startExecuteTime = System.currentTimeMillis();


    class Solution {
        int sum;
        int n;

        public boolean canVisitAllRooms(List<List<Integer>> rooms) {
            n = rooms.size();
            boolean vis[] = new boolean[n];
            dfs(rooms, 0, vis);
            return sum == n;
        }

        private void dfs(List<List<Integer>> rooms, int cur, boolean[] vis) {
            if (!vis[cur]) {
                sum++;
                vis[cur] = true;
                for (int i : rooms.get(cur)) {
                    dfs(rooms, i, vis);
                }
            }
        }
    }


    public void run() {
        Solution solution = new Solution();
        List<Integer> list = new ArrayList<>();
        System.out.println(solution.toString());
    }

    public static void main(String[] args) throws Exception {
        LC841 an = new LC841();
        an.run();

        System.out.println("\ncurrent solution total execute time: " + (System.currentTimeMillis() - an.startExecuteTime) + " ms.");
    }
}
